package com.sangeng.controller;

import com.sangeng.annotation.SystemLog;
import com.sangeng.domain.ResponseResult;
import com.sangeng.domain.dto.ArticleDto;
import com.sangeng.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ArticleController
 * Package: com.sangeng.controller
 * Description:
 *
 * @Author hjh
 * @Create 2024/8/24 23:18
 * @Version 1.0
 */
@RestController
@RequestMapping("/content/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    //新增博文接口的实现
    @SystemLog(businessName = "新增博文接口")
    @PostMapping
    public ResponseResult addArticle(@RequestBody ArticleDto articleDto){
      return articleService.addArticle(articleDto);
    }

    //文章列表
    @SystemLog(businessName = "文章列表接口")
    @GetMapping("/list")
    public ResponseResult getPageList(Long pageNum,Long pageSize,String title,String summary){
       return articleService.getPageList(pageNum,pageSize,title,summary);
    }

    //根据文章id查询文章的详细信息
    @SystemLog(businessName = "根据文章id查询文章的详细信息")
    @GetMapping("/{id}")
    public  ResponseResult getArticleById(@PathVariable Long id){
      return   articleService.getArticleById(id);
    }

    //更新文章接口
    @SystemLog(businessName = "更新文章接口")
    @PutMapping
    public ResponseResult updateArticle (@RequestBody ArticleDto articleDto){
       return articleService.updateArticle(articleDto);
    }

    //删除文章接口
    @SystemLog(businessName = "删除文章接口")
    @DeleteMapping("/{id}")
    public ResponseResult deleteArticleById(@PathVariable Long id){
      return   articleService.deleteArticleById(id);
    }
}
